package com.meilai.project.mapper.finance.supplier;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.meilai.project.entity.finance.supplier.SupplierContactInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SupplierContactInfoMapper extends BaseMapper<SupplierContactInfo> {

    @Select("select id from supplier_contact_info where deleted_at is null and supplier_id=#{supplier_id}")
    List<Long> getIdsBySupplierId(@Param("supplier_id") Long supplier_id);

    @Update("<script>" +
            "update supplier_contact_info set deleted_at=now() where id in " +
            "<foreach collection=\"ids\" item=\"item\" open=\"(\" close=\")\" separator=\",\">#{item}</foreach>" +
            "</script>")
    void updateDeletedAtByIds(@Param("ids") List<Long> ids);

}
